package com.baidu.bulls.stock.entity.user;

import com.baidu.bulls.stock.entity.base.BaseEntity;
import com.baidu.bulls.stock.entity.vo.AuthorityUserRoleVo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 用户表
 * </p>
 * @author //蔡志豪
 * @since 2022-02-18
 */
@Data
@Entity
@Api(value = "HATEOAS接口-用户管理(AuthorityUser)")
@EqualsAndHashCode(callSuper = false)
@TableName("t_authority_user")
@Table(name = "t_authority_user")
@ApiModel(value="AuthorityUser", description="用户表")
public class AuthorityUser extends BaseEntity {

    @OneToMany(targetEntity = AuthorityUserRoleVo.class,cascade = CascadeType.ALL,fetch = FetchType.EAGER)
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "userId",referencedColumnName = "id") //name是关联表指向当前表的id
    private List<AuthorityUserRoleVo> authorityUserRoleVos;

    @ApiModelProperty(value = "用户帐号（登录用）")
    @Column(name = "userAccount")
    private String userAccount;

    @ApiModelProperty(value = "用户密码")
    @Column(name = "userPassword")
    private String userPassword;

    @ApiModelProperty(value = "用户姓名")
    @Column(name = "userName")
    private String userName;

    @ApiModelProperty(value = "电话号码")
    @Column(name = "phone")
    private String phone;

    @ApiModelProperty(value = "邮箱")
    @Column(name = "email")
    private String email;

    @ApiModelProperty(value = "最后登录时间")
    @Column(name = "lastLoginTime")
    private LocalDateTime lastLoginTime;

    @ApiModelProperty(value = "最后登陆IP")
    @Column(name = "lastLoginIp")
    private String lastLoginIp;

    @ApiModelProperty(value = "用户创建时间")
    @Column(name = "createTime")
    private LocalDateTime createTime;

    @ApiModelProperty(value = "创建人的账号")
    @Column(name = "creatorUserAccount")
    private String creatorUserAccount;

    @ApiModelProperty(value = "状态（0无效1有效）")
    @Column(name = "status")
    private Integer status;

    @ApiModelProperty(value = "是否管理员（0否1是）")
    @Column(name = "isAdmin")
    private Integer isAdmin;

    @ApiModelProperty(value = "备注")
    @Column(name = "remark")
    private String remark;


}
